home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / BBS / MUBBS / MUBBS etc.cpt / Module Source / Module std routines / MUBBS Module.h < prev   
Text File  |  1991-11-11  |  11KB  |  289 lines

  1. /*
  2.  *  MUBBS Module.h
  3.  *
  4.  *    This program source code and it's compiled version is
  5.  *  Copyright (c) 1991 N. Hawthorn.
  6.  *  This program source code and it's compiled version IS NOT IN THE
  7.  *  PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NH" file for details
  8.  *  regarding use of this program source code and it's compiled version.
  9.  *
  10.  *
  11.  * Don't modify this file !
  12.  *
  13.  */
  14.  
  15. #include "MacTypes.h"
  16.  
  17. /* All of my GLOBALS and stuff for each c file to use  */
  18. /* these values MUST remain the same */
  19.  
  20. #ifndef NULL
  21. #define NULL        ((void *) 0)
  22. #endif
  23.  
  24. #define EOF                (-1)
  25. #define SEEK_SET        0
  26. #define SEEK_CUR        1
  27. #define SEEK_END        2
  28.  
  29. #define maxport 33  /* how many users we may have ever makes exactly maxport users */
  30. #define maxnamelength    33 /* max username length */
  31.  
  32. struct GS { /* all this is provided to modules for possible modification */
  33.  
  34. int
  35.     u,                   /* THIS IS THE ACTIVE USER NUMBER !! (starts at 0!)
  36.                         /* use this for every array's index ! */
  37.     users,                /* how many actual users for this particular set up */
  38.     localuser,            /* what user number the local user is (it's users -1) */
  39.     stacksize,            /* stacks for all, never over 32K !!*/
  40.     calls,              /* number of calls total since boot up */
  41.     connects,             /* number of connects since boot up */
  42.     logins,             /* number of logins since boot up */
  43.     debuglevel,            /* For debugging, will print special messages when over 1 */
  44.     resetmode,            /* 0= no system reload, 1= program reload only, 2= total reset OK */
  45.     timeminute,            /* One minute count, gets reset to 0 at 10 minutes */
  46.     noprint,            /* flag for stopping any print() to the Mac screen, for local log on */
  47.     forgetusers,        /* flag to make all ports dead, for first sysop log on */
  48.     switchcount,        /* count of times NOT switched, done in a IRQ, reset at switch */
  49.     reservedint1,        /* reserved, DO NOT USE ! */
  50.     reservedint2,        /* reserved, DO NOT USE ! */
  51.     reservedint3,        /* reserved, DO NOT USE ! */
  52.     online[maxport],    /* flag for when you are still online */
  53.     maxtime[maxport],    /* max time to timeout in input routines, in TICKS 1000=15secs 3000=45secs */
  54.     timeon[maxport],    /* minutes this user has been on this login */
  55.     timeallowed[maxport], /* minutes this user is allowed on for */
  56.     userpriv[maxport],    /* users privledge level */
  57.     userlines[maxport],    /* users terminal config for line counts */
  58.     usertimes[maxport],    /* users number of times on (to detect new users) */
  59.     logmode[maxport],    /* 0=No log file written for this user, 1=Log this user */
  60.     privacy[maxport],    /* 0=Don't bother me, handled by a Chat Module */
  61.     linecnt[maxport],    /* users actual output line count, the system does this for you */
  62.     cont[maxport],        /* users flag for continous output, no stopping */
  63.     carrdet[maxport],    /* for testing, detect carrier loss */
  64.     usedtr[maxport],    /* flag for using DTR for hang up */
  65.     nocheck[maxport],    /* flag for send to check for control characters (S or C) */
  66.     okcancel[maxport],    /* flag for text file send cancels */
  67.     cancel[maxport],    /* TRUE when cancel is pressed in the out routine */
  68.     monitor[maxport],    /* The monitor flag, if TRUE shows all output to Mac screen */
  69.     chatmode[maxport],    /* if >1 the chat module is called from in() */
  70.     local[maxport],        /* flag to tell if this user is at the Mac screen & keyboard */
  71.     language[maxport],    /* 0=english normal, 1=english with ANSI Graphics. */
  72.     noiseflag[maxport],    /* TRUE if line noise is present (if noise detect module installed) */
  73.     frontend[maxport],    /* TRUE if using a front end program (if front end module installed) */
  74.     answer[maxport],    /* TRUE if it's OK to answer the line (for maint period) */
  75.     nottransfer[maxport], /* flag for when you are not in a transfer, doesn't strip ctls */
  76.     reservedint4[maxport], /* reserved, DO NOT USE ! */
  77.     reservedint5[maxport], /* reserved, DO NOT USE ! */
  78.     reservedint6[maxport], /* reserved, DO NOT USE ! */
  79.     reservedint7[maxport], /* reserved, DO NOT USE ! */
  80.     reservedint8[maxport]; /* reserved, DO NOT USE ! */
  81.  
  82. long
  83.     newstacksize,        /* the total stack size allowed, system sets this up for you */
  84.     logincounts,        /* counter of logins total for system */
  85.     timems,                /* counter of 10 MS periods, gets reset each minute to 0 */
  86.     userfilepos[maxport], /* points to this users record in the userfile */
  87.     reservedlong1[maxport], /* reserved, DO NOT USE ! */
  88.     reservedlong2[maxport], /* reserved, DO NOT USE ! */
  89.     reservedlong3[maxport], /* reserved, DO NOT USE ! */
  90.     reservedlong4[maxport], /* reserved, DO NOT USE ! */
  91.     reservedlong5[maxport]; /* reserved, DO NOT USE ! */
  92.  
  93. float
  94.     version,            /* this release of MUBBS version number */
  95.     reservedfloat1,     /* reserved, DO NOT USE ! */
  96.     reservedfloat2,     /* reserved, DO NOT USE ! */
  97.     reservedfloat3;     /* reserved, DO NOT USE ! */
  98.  
  99. char
  100.     CR[maxport][4],            /* This is the CRLF string use this, don't do a send("]"). */
  101.     username[maxport][maxnamelength],    /* user's name */
  102.     userbaud[maxport][10],    /* user's baudrate */
  103.     userlast[maxport][maxnamelength],    /* last time user was on */
  104.     userlocation[maxport][65],    /* user's location*/
  105.     sysopname[33],    /* sysop's name for system */
  106.     systemname[41],    /* this systems's name */
  107.     modulename[maxport][27],    /* the name of the module being called now */
  108.     oldmodulename[maxport][27],    /* the calling module's name (a copy of modulename) */
  109.     keyboardbuf[50],    /* for buffering the Mac's keyborad DO NOT USE ! */
  110.     programmer[21],        /* Returned from a module, the programmers "credits" name */
  111.     reservedchar1[maxport][maxnamelength], /* reserved, DO NOT USE ! */
  112.     reservedchar2[maxport][maxnamelength], /* reserved, DO NOT USE ! */
  113.     reservedchar3[maxport][maxnamelength], /* reserved, DO NOT USE ! */
  114.     reservedchar4[maxport][maxnamelength], /* reserved, DO NOT USE ! */
  115.     reservedchar5[maxport][maxnamelength]; /* reserved, DO NOT USE ! */
  116.  
  117. unsigned char
  118.     input[maxport];
  119.  
  120. long S;        /* module call back routine pointer */
  121. ProcPtr Js; /* module call back pointer to the routine */
  122. int moduleresult;    /* module result code, only valid right after return from module */
  123.                     /* or set FALSE if module couldn't be called */
  124.  
  125. ProcPtr seropen;    /* serial port open routine pointer */
  126. ProcPtr serclose;    /* serial port close routine pointer */
  127. ProcPtr serflush;     /* serial port flush routine pointer */
  128. ProcPtr serin;        /* serial port input routine pointer */
  129. ProcPtr serout;        /* serial port output routine pointer */
  130. ProcPtr serblkin;    /* Block serial port input routine pointer */
  131. ProcPtr serblkout;    /* Block serial port output routine pointer */
  132. ProcPtr in;         /* IN routine pointer */
  133. ProcPtr out;         /* OUT routine pointer */
  134. ProcPtr blkin;        /* Block IN routine pointer */
  135. ProcPtr blkout;     /* Block OUT routine pointer */
  136.  
  137. ProcPtr event1; /* Event loop routine pointer */
  138. ProcPtr event2; /* Event loop routine pointer */
  139. ProcPtr event3; /* Event loop routine pointer */
  140. ProcPtr event4; /* Event loop routine pointer */
  141. ProcPtr event5; /* Event loop routine pointer */
  142.  
  143. ProcPtr idle1;    /* Idle loop routine pointer */
  144. ProcPtr idle2;    /* Idle loop routine pointer */
  145. ProcPtr idle3;    /* Idle loop routine pointer */
  146. ProcPtr idle4;    /* Idle loop routine pointer */
  147. ProcPtr idle5;    /* Idle loop routine pointer */
  148.  
  149. ProcPtr extra1; /* RESERVED, DO NOT USE !! */
  150. ProcPtr extra2; /* RESERVED, DO NOT USE !! */
  151. ProcPtr extra3; /* RESERVED, DO NOT USE !! */
  152. ProcPtr extra4; /* RESERVED, DO NOT USE !! */
  153. ProcPtr extra5; /* RESERVED, DO NOT USE !! */
  154.  
  155.  
  156. }; /* end of struct "GS" */
  157.  
  158.  
  159.  
  160. /* Here's where we define our globals. In the "Main" file, we make them actual */
  161. /* globals. In any others, they are "extern" so that your code can find them. */
  162. /* this is done by maknig the word "globalx" change (nothing or extern). */
  163.  
  164. #ifdef INMAIN
  165. #define globalx 
  166. #else
  167. #define globalx extern
  168. #endif
  169.  
  170. globalx struct GS *G; /* our pointer to the main module's global struct */
  171.  
  172. globalx int mode[maxport]; /* what mode this module was called in */
  173.  
  174.  
  175.  
  176. /* routines used to access the "call back" routines in the main module */
  177.  
  178. #define godoit hh=G->Js; asm{move.l hh,a1} asm{UNLK A6} asm{JMP (a1)}
  179.  
  180. /* this is so that we don't have to do the -> thing all the time ! */
  181.  
  182. #define u G->u
  183.  
  184. /* this stuff is so that we can call the "stdio" routines in the main module */
  185.  
  186. #ifndef __size_t
  187. #define __size_t
  188. typedef unsigned long size_t;
  189. #endif
  190.  
  191. typedef unsigned long fpos_t;
  192.  
  193. typedef struct {
  194.     unsigned        std : 1;
  195.     unsigned        binary : 1;
  196.     unsigned        eof : 1;
  197.     unsigned        err : 1;
  198.     unsigned        dirty : 1;
  199.     unsigned        mybuf : 1;
  200.     unsigned        append : 1;
  201.     unsigned        delete : 1;
  202.     unsigned        pushed : 1;
  203.     char            one;
  204.     unsigned char    pushc;
  205.     short            refnum;
  206.     char            *buf;
  207.     size_t            size;
  208.     unsigned char    *ptr;
  209.     size_t            cnt;
  210.     fpos_t            pos;
  211.     fpos_t            len;
  212.     void            *window;
  213.     int                (*proc)();
  214. } FILE;
  215.  
  216. /* are we in the "MUBBS Misc.c" file ?, if so don't compile this */
  217.  
  218. #ifndef INMUBBSMISC
  219.  
  220. extern int remove(char *);
  221. extern int rename(char *, char *);
  222. extern FILE *tmpfile(void);
  223. extern char *tmpnam(char *);
  224.  
  225. extern int fclose(FILE *);
  226. extern int fflush(FILE *);
  227. extern FILE *fopen(char *, char *);
  228. extern FILE *freopen(char *, char *, FILE *);
  229. extern void setbuf(FILE *, char *);
  230. extern int setvbuf(FILE *, char *, int, size_t);
  231.  
  232. extern int fprintf(FILE *, char *, ...);
  233. extern int fscanf(FILE *, char *, ...);
  234. extern int printf(char *, ...);
  235. extern int scanf(char *, ...);
  236. extern int sprintf(char *, char *, ...);
  237. extern int sscanf(char *, char *, ...);
  238. extern int vfprintf(FILE *, char *, void *);
  239. extern int vprintf(char *, void *);
  240. extern int vsprintf(char *, char *, void *);
  241. extern int _vscanf(char *, void *);
  242. extern int _vsscanf(char *, char *, void *);
  243. extern int _vfscanf(FILE *, char *, void *);
  244.  
  245. extern int fgetc(FILE *);
  246. extern char *fgets(char *, int, FILE *);
  247. extern int fputc(int, FILE *);
  248. extern int fputs(char *, FILE *);
  249. extern int getc(FILE *);
  250. extern int getchar(void);
  251. extern char *gets(char *);
  252. extern int putc(int, FILE *);
  253. extern int putchar(int);
  254. extern int puts(char *);
  255. extern int ungetc(int, FILE *);
  256.  
  257. extern size_t fread(void *, size_t, size_t, FILE *);
  258. extern size_t fwrite(void *, size_t, size_t, FILE *);
  259.  
  260. extern int fgetpos(FILE *, fpos_t *);
  261. extern int fseek(FILE *, long, int);
  262. extern int fsetpos(FILE *, fpos_t *);
  263. extern long ftell(FILE *);
  264. extern void rewind(FILE *);
  265.  
  266. extern void clearerr(FILE *);
  267. extern int feof(FILE *);
  268. extern int ferror(FILE *);
  269. extern void perror(char *);
  270.  
  271. #endif
  272.  
  273. /* this should allow you to access these routines */
  274.  
  275. int __getc(FILE *);
  276. int __putc(int, FILE *);
  277.  
  278. #define getc(fp)    ((fp)->cnt-- ? (int) *(fp)->ptr++ : __getc(fp))
  279. #define getchar()    getc(stdin)
  280.  
  281. #define putc(c, fp)    ((fp)->cnt-- > 1 ? (int) (*(fp)->ptr++ = (c)) : __putc(c, fp))
  282. #define putchar(c)    putc(c, stdout)
  283.  
  284. #define ferror(fp)    ((int) (fp)->err)
  285. #define feof(fp)    ((int) (fp)->eof)
  286.  
  287.  
  288.  
  289.